﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wpfui="http://schemas.lepo.co/wpfui/2022/xaml">

    <!--  ReSharper disable Xaml.StaticResourceNotResolved  -->

    <!--
        Always visible scrollbar when mouse is over DynamicScrollViewer
    -->
    <ControlTemplate x:Key="DynamicVerticalScrollBar" TargetType="{x:Type wpfui:DynamicScrollBar}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition MaxHeight="14" />
                <RowDefinition Height="0.00001*" />
                <RowDefinition MaxHeight="14" />
            </Grid.RowDefinitions>
            <RepeatButton
                x:Name="PART_ButtonScrollUp"
                Grid.Row="0"
                Command="ScrollBar.LineUpCommand"
                Content="{x:Static wpfui:SymbolRegular.ChevronUp24}"
                Opacity="0"
                Style="{StaticResource DynamicScrollBarLineButton}" />
            <Track
                x:Name="PART_Track"
                Grid.Row="1"
                Width="6"
                IsDirectionReversed="True"
                Opacity="0">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource DynamicScrollBarPageButton}" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <!--
                        TODO: Need to add a custom Thumb with a corner radius that will increase when OnMouseOver is triggered.
                    -->
                    <Thumb
                        Margin="0"
                        Padding="0"
                        Style="{StaticResource DynamicScrollBarThumb}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource DynamicScrollBarPageButton}" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton
                x:Name="PART_ButtonScrollDown"
                Grid.Row="2"
                Command="ScrollBar.LineDownCommand"
                Content="{x:Static wpfui:SymbolRegular.ChevronDown24}"
                Opacity="0"
                Style="{StaticResource DynamicScrollBarLineButton}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation
                                Storyboard.TargetName="PART_Track"
                                Storyboard.TargetProperty="Width"
                                From="6"
                                To="10"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                            <DoubleAnimation
                                Storyboard.TargetName="PART_ButtonScrollUp"
                                Storyboard.TargetProperty="Opacity"
                                From="0.0"
                                To="1.0"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                            <DoubleAnimation
                                Storyboard.TargetName="PART_ButtonScrollDown"
                                Storyboard.TargetProperty="Opacity"
                                From="0.0"
                                To="1.0"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation
                                Storyboard.TargetName="PART_Track"
                                Storyboard.TargetProperty="Width"
                                From="10"
                                To="6"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                            <DoubleAnimation
                                Storyboard.TargetName="PART_ButtonScrollUp"
                                Storyboard.TargetProperty="Opacity"
                                From="1.0"
                                To="0.0"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                            <DoubleAnimation
                                Storyboard.TargetName="PART_ButtonScrollDown"
                                Storyboard.TargetProperty="Opacity"
                                From="1.0"
                                To="0.0"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=wpfui:DynamicScrollViewer, AncestorLevel=1}, Path=IsMouseOver}" Value="True">
                <DataTrigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation
                                Storyboard.TargetName="PART_Track"
                                Storyboard.TargetProperty="Opacity"
                                From="0.0"
                                To="1.0"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
                <DataTrigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation
                                Storyboard.TargetName="PART_Track"
                                Storyboard.TargetProperty="Opacity"
                                From="1.0"
                                To="0.0"
                                Duration="{StaticResource DynamicScrollAnimationDuration}" />
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.ExitActions>
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style BasedOn="{StaticResource UiDynamicScrollBar}" TargetType="{x:Type wpfui:DynamicScrollBar}">
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Template" Value="{StaticResource DynamicVerticalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ReSharper restore Xaml.StaticResourceNotResolved  -->

</ResourceDictionary>